<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html>
<html>
<head>
<title></title>
<%@include file="../../commons/meta.jsp"%>
<base href="${ctx}">
<meta charset="utf-8">
<link rel="stylesheet" href="${ctx}assets/plugins/pure/pure-min.css" media="all" />
<script type="text/javascript">
    debugs("${ctx} --- auth-update.jsp");
    function validateForm() {
        if (empty($("#authCode").val())) {
            alertError('<fmt:message key='Please.enter.the.access.code'/>');
            return false;
        }
        if (empty($("#authName").val())) {
            alertError('<fmt:message key='Please.enter.the.name'/>');
            return false;
        }
        if (empty($("#parentAuthCode").val())) {
            alertError('<fmt:message key='Please.select.the.parent.authority'/>');
            return false;
        }
        if (empty($("#status").val())) {
            alertError('<fmt:message key='Please.select.a.state'/>');
            return false;
        }
        /*     if(empty($("#authType").val())){
         alertError('<fmt:message key='Please.select.a.permission.types'/>');
         return false;
         } */
        if (empty($("#authSeq").val())) {
            alertError('<fmt:message key='Please.set.the.permissions.Numbers'/>');
            return false;
        }
        if (isNaN($("#authSeq").val())) {
            alertError('<fmt:message key='Access.number.must.be.numeric'/>');
            return false;
        }
        $("#forms").submit();
    }

    jQuery(document).ready(function() {
        $("#back_btn").click(function() {
            window.location.href = "${ctx}admin/adminauth";
        });
    });
</script>
</head>
<body>
    <%@include file="../../commons/head.jsp"%>
    <div class="content">
        <%@include file="../../commons/menu.jsp"%>
        <!--右侧展示部分-->
        <div class="right-zq">
            <!--center content-->
            <div class="dynamic">
                <div class="role dynamiclayer" style="display: block;">
                    <div class="title orange2">
                        <span class="left"><fmt:message key='User.permissions' /></span><label> > </label><span><fmt:message key='privilege' /></span><label> > </label><span><fmt:message
                                key='Modify.the' /></span>
                    </div>
                    <!-- 表单提交成功后如果需要关闭弹出层，可以添加这个隐藏制度按 -->
                    <input style="display: none;" type="text" id="updateOK" value="1">
                    <form class="pure-form pure-form-aligned" id="forms" method="post" action="${ctx}admin/adminauth/update">
                        <div class="news-table">
                            <table>
                                <tr>
                                    <td class="item"><fmt:message key='Access.code' />:</td>
                                    <td width="40%"><input id="authCode" name="authCode" type="text" placeholder="" value="${obj.authCode }" readonly="readonly" /></td>
                                    <td><span class="small"><fmt:message key='English.or.number' /></span></td>
                                </tr>
                                <tr>
                                    <td class="item"><fmt:message key='Permission.to.name' />:</td>
                                    <td width="40%"><input id="authName" name="authName" type="text" placeholder="" value="${obj.authName }" /></td>
                                    <td><span class="small"><fmt:message key='English.or.number' /></span></td>
                                </tr>
                                <tr>
                                    <td class="item"><fmt:message key='parent.encoding' />:</td>
                                    <td class="pure-td"><select id="parentAuthCode" name="parentAuthCode" style="text-align: center;">
                                            <option value="ROOT"><fmt:message key='root' /></option>
                                            <c:if test="${authlist !=null and not empty authlist}">
                                                <c:forEach items="${authlist}" var="objl" varStatus="status">
                                                    <option value="${objl.key}" <c:if test="${obj.parentAuthCode == objl.key }">selected="selected"</c:if>>${objl.value }</option>
                                                </c:forEach>
                                            </c:if>
                                    </select></td>
                                </tr>
                                <tr>
                                    <td class="item"><fmt:message key='status' />:</td>
                                    <td class="pure-td"><select id="status" name="status" style="text-align: center;" style="text-align: center;">
                                            <option value="0" <c:if test="${obj.status == 0 }">selected="selected"</c:if>><fmt:message key='disable' /></option>
                                            <option value="1" <c:if test="${obj.status == 1 }">selected="selected"</c:if>><fmt:message key='available' /></option>
                                            <!-- <option value="-1" <c:if test="${obj.status == -1 }">selected="selected"</c:if> >删除</option>  -->
                                    </select></td>
                                </tr>
                                <%-- <tr>
                                    <td class="item"><fmt:message key='Permission.types'/>:</td>
                                    <td width="40%" class="pure-td">
                                        <select id="authType" name="authType"style="text-align: center;"> 
                                            <option value="1" <c:if test="${obj.authType == 1 }">selected="selected"</c:if> ><fmt:message key='menu'/></option>
                                            <option value="2" <c:if test="${obj.authType == 2 }">selected="selected"</c:if> ><fmt:message key='button'/></option>
                                            <option value="3" <c:if test="${obj.authType == 3 }">selected="selected"</c:if> ><fmt:message key='data'/></option>
                                        </select>
                                    </td> 
                                </tr> --%>
                                <tr>
                                    <td class="item"><fmt:message key='Access.number' />:</td>
                                    <td width="40%"><input id="authSeq" name="authSeq" type="text" placeholder="" value="${obj.authSeq }" /></td>
                                </tr>
                                <%-- <tr>
                                    <td class="item">URL:</td>
                                    <td width="40%">
                                        <input id="authUrl" name="authUrl" type="text"  placeholder="" value="${obj.authUrl }" />
                                    </td> 
                                </tr> --%>
                                <tr>
                                    <td></td>
                                    <td width="40%">
                                        <button class="orange2" type="button" onclick="validateForm()">
                                            <fmt:message key='sys.save' />
                                            &nbsp;<i class="fa fa-floppy-o"></i>
                                        </button> &nbsp;&nbsp;
                                        <button class="orange2" type="button" id="back_btn">
                                            <fmt:message key='sys.retu' />
                                            &nbsp;<i class="fa fa-undo"></i>
                                        </button>
                                    </td>
                                    <td></td>
                                </tr>
                            </table>
                        </div>
                    </form>
                    <%@include file="../../commons/footpop.jsp"%>
                    <!-- 页尾，提示消息 -->
                    <jsp:include page="../../commons/foot_message.jsp"></jsp:include>
                </div>
            </div>
        </div>
    </div>
<script>
    jQuery(document).ready(function() {
        var webStatust = $("#webStatus").html();
        if (empty(webStatust)) {
            return;
        } else if (webStatust == 200) {
            parent.listFormPageSearch(1);
        }
    });
</script>
</body>
</html>